<template>
	<view class="page">
		<view class="inputbox" style="margin-top: 120upx;">
			<input :adjust-position='false' v-model="phone" placeholder="请输入账号" type="text">
		</view>
		<view class="inputbox" style="margin-top: 22upx;">
			<input :adjust-position='false' v-model="pwd" placeholder="请输入密码" type="password">
		</view>
		
		<button hover-class="other-button-hover" class="loginbtn" @click="handle">
			立即登录
		</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phone: '',
				pwd: ''
			}
		},
		onLoad() {
			
		},
		methods: {
			async handle() {
				if (!this.phone) {
					uni.showToast({
						title: '请填写账号',
						duration: 500,
						icon: 'none',
					});
					return
				}
				if (!this.pwd) {
					uni.showToast({
						title: '请填写密码',
						duration: 500,
						icon: 'none',
					});
					return
				}
				this.submit();
			},
			// 注册接口
			async submit() {
				let res = await this.$api.loginBtn({
					phone: this.phone,
					password: this.pwd
				});
				if (res.code == 200) {
					uni.setStorageSync("servicetoken",res.data.login_token);
					uni.reLaunch({
						url:'/pages/index/index'
					})
				}
			},
		}
	}
</script>

<style scoped lang="less">
	.page{
		position: absolute;
		width: 100%;
		height: 100%;
	}
	.loginbtn {
		width: 550upx;
		background: #74BC42;
		box-shadow: 0px 16upx 35upx 0px rgba(98, 164, 52, 0.32);
		border-radius: 45upx;
		font-size: 36upx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		margin-top: 100upx;
	}

	.inputbox {
		width: 660upx;
		height: 94upx;
		display: flex;
		align-items: center;
		margin: 0 auto;
		box-sizing: border-box;
		border-bottom: 2upx solid #EEEEEE;
		input {
			flex: 1;
			background-color: #FFFFFF;
			height: 60upx;
			font-size: 30upx;
			font-family: PingFang SC;
			font-weight: 500;
		}
	}
</style>
